package com.example.fp.zlz.controller;

import com.example.fp.cgc.code.logAnno.LogAnno;
import com.example.fp.zlz.entity.Game;
import com.example.fp.zlz.mapper.GameMapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 说明: game表操作
 * 编写人: 张连壮
 * 编写时间: 2019-12-31
 * 修改时间:
 * game相关操作
 */
@CrossOrigin
@RestController
public class GameController {
	@Autowired
	private GameMapper gameMapper;

	@LogAnno(operateType = "游戏查询")
	@ApiOperation("游戏查询")
	@GetMapping("/selectgame")
	public Game selectGame(int id){
		return gameMapper.selectById(id);
	}

	@LogAnno(operateType = "游戏添加")
	@ApiOperation("游戏添加")
	@PostMapping("/insertgame")
	public int insertGame(Game game){
		return gameMapper.insert(game);
	}

	@LogAnno(operateType = "游戏修改")
	@ApiOperation("游戏修改")
	@GetMapping("/updatetgame")
	public int updateGame(Game game){
		return gameMapper.updateById(game);
	}

	@LogAnno(operateType = "游戏删除")
	@ApiOperation("游戏删除")
	@DeleteMapping("/deletegame")
	public int deleteGame(int id){
		return gameMapper.deleteById(id);
	}


	//测试
	@LogAnno(operateType = "查询当前游戏列表")
	@RequestMapping(value = "/game",method = RequestMethod.GET)
	@ResponseBody
	public List<Game> selectallGame(){
		return gameMapper.selectallgame();
	}

}
